package com.pic.mgt.syushin.executer;

import com.pic.mgt.dao.syushin.ISyushinBusinessTargetActionDao;
import com.pic.mgt.executer.BusinessUnitExecuter;
import com.pic.mgt.executer.IGXTypeExecutionException;
import com.pic.mgt.executer.TargetAction;
import com.pic.mgt.manager.business.BusinessManager;

public abstract class SyushinBusinessUnitExecuter extends BusinessUnitExecuter {
	// (送多方修改)
	protected CfmtAction cfmtAction;
	
	// (送多方修改)
	protected ISyushinBusinessTargetActionDao syushinBusinessTargetActionDao;
	
	// (送多方新增)
	protected BusinessManager businessManager;
	
	public SyushinBusinessUnitExecuter(TargetAction targetAction,
						   CfmtAction cfmtAction) {
		super(targetAction);
		
		this.cfmtAction = cfmtAction;
	}
	
	@Override
	// (送多方修改)
	protected void executeIGXTypeSpecify()
									throws IGXTypeExecutionException {
		// Syushin 層級的部份沒有共通處理的地方,直接交由子類去處理
		executeIGXBusinessTypeSpecify();
	}
	
	// (送多方刪除)
	/*protected void insertSyushinTargetActionToDB(String apName) throws DataAccessException {
		try {
			Map<String, Object> insertValuesMap = getInsertValuesMap();
			// (送多方新增)
			insertValuesMap.put(SyushinBusinessTargetActionDao._apName, apName);
			this.syushinBusinessTargetActionDao.insertBasic(insertValuesMap);
		} catch (DuplicateKeyException e1) {
			// 若是在 Insert 資料時發生 Unique Key 重覆的例外
			
			
			 * 忽略之。此種情況可能發生的情形是在，當集信處理過程中發生失敗而中斷，
			 * 導致 syushin_business_target_action table 內已經存在有執行成功
			 * 的資料紀錄。這時再進行重新配信的動作時，便會發生資料有重覆 insert 的情形。
			 
			// (送多方修改)
			this.syushinBusinessTargetActionDao.updateCreatingTimeByFilenameAndApName(
					new Timestamp(new Date().getTime()), super.business.getTargetFilename(), apName);
		} catch (DataAccessException e2) {
			throw e2;
		}
	}*/
	
	// (送多方刪除)
	/*private Map<String, Object> getInsertValuesMap() {
		SyushinBusinessUnit syushinBusinessUnit =
						(SyushinBusinessUnit)super.business;
		
		Map<String, Object> insertValuesMap = new HashMap<String, Object>();
		
		insertValuesMap.put(SyushinBusinessTargetActionDao._unitName, syushinBusinessUnit.getUnitName());
		insertValuesMap.put(SyushinBusinessTargetActionDao._terminalId, syushinBusinessUnit.getTerminalID());
		insertValuesMap.put(SyushinBusinessTargetActionDao._fileName, syushinBusinessUnit.getTargetFilename());
		insertValuesMap.put(SyushinBusinessTargetActionDao._fileSize, syushinBusinessUnit.getTargetFile().length());
		
		return insertValuesMap;
	}*/
	
	/**
	 * 針對集信類別所需的其它執行動作。
	 * @throws IGXTypeExecutionException
	 */
	// (送多方新增)
	protected abstract void executeIGXBusinessTypeSpecify() throws IGXTypeExecutionException;
	
	// --- getter and setter ---

	public void setSyushinBusinessTargetActionDao(
			ISyushinBusinessTargetActionDao syushinBusinessTargetActionDao) {
		this.syushinBusinessTargetActionDao = syushinBusinessTargetActionDao;
	}
	
	// (送多方新增)
	public void setBusinessManager(BusinessManager businessManager) {
		this.businessManager = businessManager;
	}
}
